package com.edz.dudumifi.event;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.edz.dudumifi.base.Config;
import com.edz.dudumifi.utils.KKTcpClient;
import com.edz.dudumifi.utils.PreferencesUtils;

import java.util.Map;

/**
 * Created by ganshh.gan on 2018/5/16.
 */
public class KKTcpClientThread extends Thread {

    private String cmd;
    private Context context;

    public KKTcpClientThread(Context context, String cmd) {
        this.cmd = cmd;
        this.context = context;
    }

    @Override
    public void run() {
        super.run();
        String strRtn = KKTcpClient.Instance().RequestGateway("127.0.0.1", cmd);
        System.out.print(cmd + "请求返回" + strRtn.trim());
        Map map = JSONObject.parseObject(strRtn.trim(), Map.class);

        //系统消息 保存
        if (map.get("IMEI1") != null) {
            PreferencesUtils.putString(context, Config.IMEI, map.get("IMEI1").toString());
        }
    }
}
